//
// Created by dg on 2024/1/2.
//

#ifndef MY_APPLICATION_YUVRENDER_H
#define MY_APPLICATION_YUVRENDER_H

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "BLProgram.h"
#include "BLYUVTextureFrame.h"

class YUVRender {
public:
    YUVRender(int screenW, int screenH);
    ~YUVRender();

public:
    void resetRenderSize(int width, int height);
    int prepareRender(int frameWidth, int frameHeight);
    int render(uint8_t *frame, int frameWidth, int frameHeight);
private:
    int _screenW;
    int _screenH;
    GLint _positionAttr;
    GLint _textureAttr;
    GLint _mUniformTexMatrix;
    GLint _mUniformTransforms;
    GLint _unformSamplers[3];

    GLuint _frameBuffer;
    GLuint _outputTextureID;

    BLProgram *program;
    BLYUVTextureFrame *yuvTextureFrame;
};


#endif //MY_APPLICATION_YUVRENDER_H
